# List CRUD
# Create
l = []
l.append("first")
print(l)
l += ["second"]
print(l)
l = ["repeat"] * 10
print(l)
l.insert(0, "new element")
print(l)

# Retrieve
l = [1, 2, 3, 4, 5, 6, 7]
print(l)
print(l[0:3])
l = [1, 2, 3]
print(l.index(1))

# Update
l[0] = 'a_1'
print(l)
l = ['a_1', 'a_2', 'b', 'c']
print(l[0:2])
l[0:2] = 'a'
l =['a', 'b', 'c']
print(l[0:2])

# Delete
l = ['a+b', 'c*d', 'e-f']
z = l.pop()
print(l)
print(z)

# Tuple CRUD
# Creat
t = ('a', )
print(t)
t += ('c',)
print(t)
t = ('mich',) * 7
print(t)

# Retrieve
t = ('lin', 'bai',)
print(t.index('bai',))

# Dict CRUD
# Create
d = {'name': 'lin', 'gender': 'female'}
d.update({'height': 170})
print(d)
d.setdefault('name', 'bai')
print(d)
d.setdefault('weight', 100)
print(d)

# Retrive
print(d['name'])
print(d.get('body', 0))
print(d.keys())
print(d.values())
print(d.items())

# Update
d['name'] = 'bai'
print(d)
d.update({'gender': 'male'})
print(d)
d.update({'gender': 'male', 'haha': 'xixi'})
print(d)

# Delete
print(d.pop('haha'))
print(d)
print(d.popitem())
print(d)
d.clear()
print(d)

# Set CRUD
# Create
s = {'a', 'b', 'c'}
print(s)
s.add('d')
print(s)
s.update({1, 2, 3})
print(s)

# Retirve
print('a' in s)

# Delete
s.remove('a')
print(s)